package org.sean.framework.sync;

import org.sean.framework.annotation.SyncCollection;
import org.sean.framework.annotation.SyncMethod;
import org.sean.framework.annotation.SyncNormal;
import org.sean.framework.annotation.SyncObject;
import org.sean.framework.util.ThreadUtil;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class Synchronize {

    @SyncNormal(index = 0)
    public void testNormal(String tt) {
        System.out.println("testNormal");
    }

    @SyncObject(index = 0, key = "query")
    public void testObj(SyncReq tt) {
        System.out.println("testObj");
    }

    @SyncCollection(index = 0, keyIndex = 1, key = "query|data.data")
    public void testCollection(List<SyncReq> tt) {
        System.out.println("testCollection");
    }

    @SyncMethod
    public void testMethod(String tt) {
        System.out.println("testMethod");
    }

    @SyncMethod(timeout = 2000)
    public void testMethodTimeout(String tt) {
        System.out.println("testMethod Timeout");
        ThreadUtil.sleep(8000);
    }
}
